package com.itheima.publisher;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class PublisherApplication implements CommandLineRunner {
    
    @Autowired
    private TopicDemo topicDemo;
    
    public static void main(String[] args) {
        SpringApplication.run(PublisherApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        // 启动后延迟2秒发送Topic消息，确保消费者已启动
        Thread.sleep(2000);
        topicDemo.sendTopicMessages();
    }
}
